package Recursion;
//假设需要将A上放到C上
public class HanoiTower {
    public static void main(String[]args){
    Hanoi tower = new Hanoi();
    tower.tower(3,'a','b','c');
    }
}

class Hanoi{
    public void tower(int n,char a,char b,char c){
        //如果只有一个，直接a放到c
        if(n==1){
            System.out.println(a+" --> "+c);
        }
        //如果不止一个，先把n-1个从a经过c放到b上
        //再把最下面的从a放到c上
        //再把b上的n-1个经a放到c上
        else{
            tower(n-1,a,c,b);
            System.out.println(a+" --> "+c);
            tower(n-1,b,a,c);
        }
    }
}
